﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="Unread.App.Views.AddFeedPage"
    DataContext="{Binding}"
    d:DataContext="{Binding Source={d:DesignInstance Type=local:DesignDataContext, IsDesignTimeCreatable=True}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Unread.App.Views"
    xmlns:common="using:Unread.App.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Style="{StaticResource LayoutRootStyle}" Loaded="Grid_Loaded_1">
        <Grid.RowDefinitions>
            <RowDefinition Height="140"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}" />
            <Grid Grid.Column="1" VerticalAlignment="Bottom">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <ProgressBar Grid.Row="0" IsIndeterminate="True" Height="10" HorizontalAlignment="Stretch" VerticalAlignment="Top" Visibility="{Binding IsLoading, Converter={StaticResource booleanToVisibilityConverter}}" />
                <StackPanel Grid.Row="1" Orientation="Horizontal">
                    <Image Source="ms-appx:///Assets/Logo.png" Height="40" VerticalAlignment="Top" Margin="0,0,20,0" />
                    <TextBlock x:Name="pageTitle" Text="Add feed" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}"/>
                </StackPanel>
            </Grid>
        </Grid>

        <StackPanel Grid.Row="1" Margin="116,0,40,46">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <TextBox x:Name="Url" InputScope="Url" Grid.Column="0" Text="{Binding Url, Mode=TwoWay}" />
                <StackPanel Grid.Column="1" Orientation="Horizontal">
                    <Button x:Name="Save" Tag="Save" Content="Add" Margin="25,0,0,0"
                                Command="{Binding AddFeedCommand}" CommandParameter="{Binding ElementName=Url, Path=Text}" />
                </StackPanel>
            </Grid>

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50*"/>
                    <ColumnDefinition Width="50*"/>
                </Grid.ColumnDefinitions>
                <StackPanel HorizontalAlignment="Left">
                    <TextBlock Text="Example: http://example.com/rss" Style="{StaticResource BasicTextStyle}"></TextBlock>
                </StackPanel>
                <StackPanel HorizontalAlignment="Right" Grid.Column="1">
                    <TextBlock Text="{Binding ErrorMessage}" Style="{StaticResource BasicTextStyle}"></TextBlock>
                </StackPanel>
            </Grid>
        </StackPanel>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!-- The back button and title have different styles when snapped -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>

    <Page.BottomAppBar>
        <AppBar x:Name="BottomAppBar1" Padding="10,0,10,0" AutomationProperties.Name="Bottom App Bar" Loaded="BottomAppBar1_Loaded" Margin="1,0,-1,0">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50*"/>
                    <ColumnDefinition Width="50*"/>
                </Grid.ColumnDefinitions>
                <StackPanel x:Name="LeftPanel" Orientation="Horizontal" Grid.Column="0" HorizontalAlignment="Left">
                    <Button x:Name="Home" Style="{StaticResource HomeAppBarButtonStyle}" Tag="Home" Command="{Binding HomeCommand}" />
                </StackPanel>
                <StackPanel x:Name="RightPanel" Orientation="Horizontal" Grid.Column="1" HorizontalAlignment="Right">
                </StackPanel>
            </Grid>
        </AppBar>
    </Page.BottomAppBar>
</common:LayoutAwarePage>
